package com.hk.service.sys.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hk.commons.HqlFilter;
import com.hk.commons.LongId;
import com.hk.commons.entity.sys.SysRoleModules;
import com.hk.dao.base.impl.BaseServiceImpl;
import com.hk.service.sys.ISysRoleModules;

@Service
public class SysRoleModulesImpl extends BaseServiceImpl<SysRoleModules>
		implements ISysRoleModules {

	@Override
	public List<SysRoleModules> getByRoleId(Long roleId) {
		HqlFilter hqlFilter = new HqlFilter();
		hqlFilter.addEQFilter("t.roleId", roleId);
		return findByFilter(hqlFilter);
	}

	@Override
	public List<SysRoleModules> getByModuleId(Long moduleId) {
		HqlFilter hqlFilter = new HqlFilter();
		hqlFilter.addEQFilter("t.moduleId", moduleId);
		return findByFilter(hqlFilter);
	}

	@Override
	public SysRoleModules getById(Long id) {
		return getById(id);
	}

	@Override
	public SysRoleModules delete(Long id) {
		SysRoleModules model = new SysRoleModules();
		model.setId(id);
		delete(model);
		return model;
	}

	@Override
	public Long add(SysRoleModules model) {
		Long id = LongId.get();
		model.setId(id);
		model.setCreatedts( System.currentTimeMillis());
		super.save(model);
		return id;
	}

}
